//
//  SandBoxViewController.m
//  MyProject
//
//  Created by yun on 2018/4/24.
//  Copyright © 2018年 yun. All rights reserved.
//

#import "SandBoxViewController.h"

@interface SandBoxViewController ()

@end

@implementation SandBoxViewController

/*
 沙盒：
 1、Documents:保存应用运行时生成的需要持久化的数据,iTunes会自动备份该目录。
 苹果建议将在应用程序中浏览到的文件数据保存在该目录下
 
 2、Library
 ①Caches:缓存，如图片视频等，此目录下的文件不会再应用程序退出时删除。iTunes不会备份该目录。
 ②Preferences:偏好设置。通过NSUserDefault这个类来访问应用程序的偏好设置
 *iTunes会自动备份该文件目录下的内容。
 比如说:是否允许访问图片,是否允许访问地理位置...
 
 3、tmp:临时文件目录，在程序重新运行的时候，和开机的时候，会清空tmp文件夹。
 */

- (void)viewDidLoad {
    [super viewDidLoad];
    // 沙盒home目录
    NSString *homePath = NSHomeDirectory();
    /*
     Documents文件路径
     
     NSDocumentDirectory:表示需要查找的是Document文件夹
     NSUserDomainMask:用户的主目录中查找
     YES:返回路径展开
     */
    NSArray<NSString *> *dPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsPath = [dPaths lastObject];
    
    /*
     Library文件路径
     Library/Caches
     Library/Preferences
     */
    
    NSString *libPath = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES).lastObject;
    NSString *libCachePath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).lastObject;
    NSString *libPrePath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES).lastObject stringByAppendingPathComponent:@"Preferences"];
    
    /*
     tmp文件路径
     /Users/yun/Library/Developer/CoreSimulator/Devices/AD64631B-712F-43E9-908B-FC869FD55C87/data/Containers/Data/Application/59CD5316-C835-40C3-9A10-90158BF5F171/tmp/
     */
    NSString *tmpPath = NSTemporaryDirectory();
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
